package com.medical.doctor.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.medical.doctor.entity.DoctorDepartmentEntity;
import com.medical.doctor.service.DoctorDepartmentService;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.R;



/**
 * 
 *
 * @author wen
 * @email 1023076426@qq.com
 * @date 2021-08-13 20:09:06
 */
@RestController
@RequestMapping("doctor/doctordepartment")
public class DoctorDepartmentController {
    @Autowired
    private DoctorDepartmentService doctorDepartmentService;




    /**
     * 医院下的所有科室
     */
    @RequestMapping("/list/{hospitalId}")
    public R listByhospitalId(@RequestParam Map<String, Object> params,@PathVariable("hospitalId")Integer hospitalId){
        PageUtils page = doctorDepartmentService.queryPageById(params,hospitalId);

        return R.ok().put("page", page);
    }



    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = doctorDepartmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{departmentId}")
    public R info(@PathVariable("departmentId") Integer departmentId){
		DoctorDepartmentEntity doctorDepartment = doctorDepartmentService.getById(departmentId);

        return R.ok().put("doctorDepartment", doctorDepartment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DoctorDepartmentEntity doctorDepartment){
		doctorDepartmentService.save(doctorDepartment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DoctorDepartmentEntity doctorDepartment){
		doctorDepartmentService.updateById(doctorDepartment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] departmentIds){
		doctorDepartmentService.removeByIds(Arrays.asList(departmentIds));

        return R.ok();
    }

}
